package com.lovo.roomProject.student.service.impl;

import com.lovo.roomProject.pojo.CutPageBean;
import com.lovo.roomProject.pojo.StudentDO;
import com.lovo.roomProject.student.dao.StudentDAO;
import com.lovo.roomProject.student.dao.impl.StudentDAOImpl;
import com.lovo.roomProject.student.service.StudentService;

import java.util.List;

public class StudentServiceImpl implements StudentService {
    private StudentDAO studentDAO=new StudentDAOImpl();
    @Override
    public List listStudent() {
        return studentDAO.listStudent();
    }

    @Override
    public StudentDO getStudentID(int id) {
        return studentDAO.getStudentID(id);
    }

    @Override
    public void insert(StudentDO studentDO) {
        studentDAO.insert(studentDO);

    }

    @Override
    public void delete(int id) {
        studentDAO.delete(id);
    }

    @Override
    public void update(StudentDO studentDO) throws Exception{
        StudentDO lodStudentDO=studentDAO.getStudentID(studentDO.getId());
        if (lodStudentDO.getRoom() !=null && lodStudentDO.getRoom().getId()==studentDO.getRoom().getId()){
            throw new Exception("你没有更换房间");
        }
        studentDAO.update(studentDO);
    }

    @Override
    public CutPageBean listStudentPage(int current,String studentName,String classzName,String roomName) {
        return studentDAO.listStudentPage(current,studentName,classzName,roomName);
    }


}
